package com.chanzany.state.case1;

/**
 * @Author ChanZany
 * @Date 2021/10/20 14:10
 * @Version 1.0
 * 抽象状态类
 */
public abstract class AbstractState {
    protected ScoreContext context;  //环境
    protected String stateName; //状态名
    protected int score;        //分数

    public abstract void checkState();  //检查当前状态

    public void addScore(int x){
        score+=x;
        System.out.println("加上："+x+"分，当前分数："+score);
        checkState();
        System.out.println("当前状态："+context.getState().stateName);
    }
}
